home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import com.sun.java.accessibility.Accessible;
- import com.sun.java.accessibility.AccessibleContext;
- import com.sun.java.swing.event.EventListenerList;
- import com.sun.java.swing.event.PopupMenuEvent;
- import com.sun.java.swing.event.PopupMenuListener;
- import com.sun.java.swing.plaf.PopupMenuUI;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Dimension;
- import java.awt.Frame;
- import java.awt.Graphics;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Insets;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.Window;
- import java.awt.event.KeyEvent;
- import java.awt.event.MouseEvent;
- import java.beans.PropertyChangeListener;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.Serializable;
- import java.util.Hashtable;
- import java.util.Vector;
-
- public class JPopupMenu extends JComponent implements Accessible, MenuElement {
- transient Component invoker;
- transient Popup popup;
- transient Frame frame;
- private String label;
- private boolean paintBorder;
- private Insets margin;
- private int desiredLocationX;
- private int desiredLocationY;
- private int lastPopupType;
- private static final Object heavyPopupCacheKey = new StringBuffer("JPopupMenu.heavyPopupCache");
- private static final Object lightPopupCacheKey = new StringBuffer("JPopupMenu.lightPopupCache");
- private static final Object mediumPopupCacheKey = new StringBuffer("JPopupMenu.mediumPopupCache");
- private static final Object defaultLWPopupEnabledKey = new StringBuffer("JPopupMenu.defaultLWPopupEnabledKey");
- private static final int MAX_CACHE_SIZE = 5;
- private transient MouseGrabber mouseGrabber;
- private boolean lightWeightPopupEnabled;
- private static final int LIGHT_WEIGHT_POPUP = 0;
- private static final int MEDIUM_WEIGHT_POPUP = 1;
- private static final int HEAVY_WEIGHT_POPUP = 2;
- private SingleSelectionModel selectionModel;
- static Class class$com$sun$java$swing$event$PopupMenuListener;
-
- public JPopupMenu() {
- this((String)null);
- }
-
- public JPopupMenu(String label) {
- this.label = null;
- this.paintBorder = true;
- this.margin = null;
- this.lastPopupType = 0;
- this.lightWeightPopupEnabled = true;
- this.label = label;
- ((Container)this).setLayout(new GridBagLayout());
- this.lightWeightPopupEnabled = getDefaultLightWeightPopupEnabled();
- this.setSelectionModel(new DefaultSingleSelectionModel());
- ((Component)this).addMouseListener(new 1());
- this.updateUI();
- }
-
- public JMenuItem add(Action a) {
- JMenuItem mi = new JMenuItem((String)a.getValue("Name"), (Icon)a.getValue("SmallIcon"));
- ((AbstractButton)mi).setHorizontalTextPosition(4);
- ((AbstractButton)mi).setVerticalTextPosition(0);
- mi.setEnabled(a.isEnabled());
- ((AbstractButton)mi).addActionListener(a);
- this.add(mi);
- PropertyChangeListener actionPropertyChangeListener = this.createActionChangeListener(mi);
- a.addPropertyChangeListener(actionPropertyChangeListener);
- return mi;
- }
-
- public JMenuItem add(JMenuItem menuItem) {
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.fill = 2;
- gbc.gridx = 0;
- gbc.gridy = ((Container)this).getComponentCount() + 1;
- super.add(menuItem, gbc);
- return menuItem;
- }
-
- public Component add(Component c) {
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.fill = 2;
- gbc.gridx = 0;
- gbc.gridy = ((Container)this).getComponentCount() + 1;
- super.add(c, gbc);
- return c;
- }
-
- public void addPopupMenuListener(PopupMenuListener l) {
- EventListenerList var10000 = super.listenerList;
- Class var10001 = class$com$sun$java$swing$event$PopupMenuListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.PopupMenuListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$com$sun$java$swing$event$PopupMenuListener = var10001;
- }
-
- var10000.add(var10001, l);
- }
-
- public void addSeparator() {
- this.add((Component)(new JSeparator()));
- }
-
- private boolean ancestorIsDialog(Component i) {
- for(Container parent = i.getParent(); parent != null; parent = ((Component)parent).getParent()) {
- if (parent instanceof Dialog) {
- return true;
- }
- }
-
- return false;
- }
-
- protected PropertyChangeListener createActionChangeListener(JMenuItem b) {
- return new ActionChangedListener(this, b);
- }
-
- private Popup createHeavyWeightPopup() {
- Frame frame = getFrame(this.invoker);
- if (frame != null) {
- this.popup = getRecycledHeavyPopup(frame);
- } else {
- frame = new Frame();
- }
-
- if (this.popup == null) {
- this.popup = new WindowPopup(this, frame);
- }
-
- return this.popup;
- }
-
- private Popup createLightWeightPopup() {
- Popup popup = getRecycledLightPopup();
- if (popup == null) {
- popup = new JPanelPopup(this);
- }
-
- return (Popup)popup;
- }
-
- private Popup createMediumWeightPopup() {
- Popup popup = getRecycledMediumPopup();
- if (popup == null) {
- popup = new PanelPopup(this);
- }
-
- return (Popup)popup;
- }
-
- protected void firePopupMenuCanceled() {
- Object[] listeners = super.listenerList.getListenerList();
- PopupMenuEvent e = null;
-
- for(int i = listeners.length - 2; i >= 0; i -= 2) {
- Object var10000 = listeners[i];
- Class var10001 = class$com$sun$java$swing$event$PopupMenuListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.PopupMenuListener");
- } catch (ClassNotFoundException var4) {
- throw new NoClassDefFoundError(((Throwable)var4).getMessage());
- }
-
- class$com$sun$java$swing$event$PopupMenuListener = var10001;
- }
-
- if (var10000 == var10001) {
- if (e == null) {
- e = new PopupMenuEvent(this);
- }
-
- ((PopupMenuListener)listeners[i + 1]).popupMenuCanceled(e);
- }
- }
-
- }
-
- protected void firePopupMenuWillBecomeInvisible() {
- Object[] listeners = super.listenerList.getListenerList();
- PopupMenuEvent e = null;
-
- for(int i = listeners.length - 2; i >= 0; i -= 2) {
- Object var10000 = listeners[i];
- Class var10001 = class$com$sun$java$swing$event$PopupMenuListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.PopupMenuListener");
- } catch (ClassNotFoundException var4) {
- throw new NoClassDefFoundError(((Throwable)var4).getMessage());
- }
-
- class$com$sun$java$swing$event$PopupMenuListener = var10001;
- }
-
- if (var10000 == var10001) {
- if (e == null) {
- e = new PopupMenuEvent(this);
- }
-
- ((PopupMenuListener)listeners[i + 1]).popupMenuWillBecomeInvisible(e);
- }
- }
-
- }
-
- protected void firePopupMenuWillBecomeVisible() {
- Object[] listeners = super.listenerList.getListenerList();
- PopupMenuEvent e = null;
-
- for(int i = listeners.length - 2; i >= 0; i -= 2) {
- Object var10000 = listeners[i];
- Class var10001 = class$com$sun$java$swing$event$PopupMenuListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.PopupMenuListener");
- } catch (ClassNotFoundException var4) {
- throw new NoClassDefFoundError(((Throwable)var4).getMessage());
- }
-
- class$com$sun$java$swing$event$PopupMenuListener = var10001;
- }
-
- if (var10000 == var10001) {
- if (e == null) {
- e = new PopupMenuEvent(this);
- }
-
- ((PopupMenuListener)listeners[i + 1]).popupMenuWillBecomeVisible(e);
- }
- }
-
- }
-
- public AccessibleContext getAccessibleContext() {
- if (super.accessibleContext == null) {
- super.accessibleContext = new AccessibleJPopupMenu(this);
- }
-
- return super.accessibleContext;
- }
-
- public Component getComponent() {
- return this;
- }
-
- public Component getComponentAtIndex(int i) {
- int ncomponents = ((Container)this).getComponentCount();
- if (i <= ncomponents) {
- Component[] component = ((Container)this).getComponents();
- return component[i];
- } else {
- return null;
- }
- }
-
- public int getComponentIndex(Component c) {
- int ncomponents = ((Container)this).getComponentCount();
- Component[] component = ((Container)this).getComponents();
-
- for(int i = 0; i < ncomponents; ++i) {
- Component comp = component[i];
- if (comp == c) {
- return i;
- }
- }
-
- return -1;
- }
-
- public static boolean getDefaultLightWeightPopupEnabled() {
- Boolean b = (Boolean)SwingUtilities.appContextGet(defaultLWPopupEnabledKey);
- if (b == null) {
- SwingUtilities.appContextPut(defaultLWPopupEnabledKey, Boolean.TRUE);
- return true;
- } else {
- return b;
- }
- }
-
- private static Frame getFrame(Component c) {
- Component w;
- for(w = c; !(w instanceof Frame) && w != null; w = w.getParent()) {
- }
-
- return (Frame)w;
- }
-
- private static Hashtable getHeavyPopupCache() {
- Hashtable cache = (Hashtable)SwingUtilities.appContextGet(heavyPopupCacheKey);
- if (cache == null) {
- cache = new Hashtable(2);
- SwingUtilities.appContextPut(heavyPopupCacheKey, cache);
- }
-
- return cache;
- }
-
- public Component getInvoker() {
- return this.invoker;
- }
-
- public String getLabel() {
- return this.label;
- }
-
- private static Vector getLightPopupCache() {
- Vector cache = (Vector)SwingUtilities.appContextGet(lightPopupCacheKey);
- if (cache == null) {
- cache = new Vector();
- SwingUtilities.appContextPut(lightPopupCacheKey, cache);
- }
-
- return cache;
- }
-
- public Insets getMargin() {
- return this.margin == null ? new Insets(0, 0, 0, 0) : this.margin;
- }
-
- private static Vector getMediumPopupCache() {
- Vector cache = (Vector)SwingUtilities.appContextGet(mediumPopupCacheKey);
- if (cache == null) {
- cache = new Vector();
- SwingUtilities.appContextPut(mediumPopupCacheKey, cache);
- }
-
- return cache;
- }
-
- static synchronized Popup getRecycledHeavyPopup(Frame f) {
- Hashtable heavyPopupCache = getHeavyPopupCache();
- if (heavyPopupCache.containsKey(f)) {
- Vector cache = (Vector)heavyPopupCache.get(f);
- if (cache.size() > 0) {
- Popup r = (Popup)cache.elementAt(0);
- cache.removeElementAt(0);
- return r;
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- static synchronized Popup getRecycledLightPopup() {
- Vector lightPopupCache = getLightPopupCache();
- if (lightPopupCache.size() > 0) {
- Popup r = (Popup)lightPopupCache.elementAt(0);
- lightPopupCache.removeElementAt(0);
- return r;
- } else {
- return null;
- }
- }
-
- static synchronized Popup getRecycledMediumPopup() {
- Vector mediumPopupCache = getMediumPopupCache();
- if (mediumPopupCache.size() > 0) {
- Popup r = (Popup)mediumPopupCache.elementAt(0);
- mediumPopupCache.removeElementAt(0);
- return r;
- } else {
- return null;
- }
- }
-
- JPopupMenu getRootPopupMenu() {
- JPopupMenu mp;
- for(mp = this; mp != null && !mp.isPopupMenu() && mp.getInvoker() != null && mp.getInvoker().getParent() != null && mp.getInvoker().getParent() instanceof JPopupMenu; mp = (JPopupMenu)mp.getInvoker().getParent()) {
- }
-
- return mp;
- }
-
- public SingleSelectionModel getSelectionModel() {
- return this.selectionModel;
- }
-
- public MenuElement[] getSubElements() {
- Vector tmp = new Vector();
- int c = ((Container)this).getComponentCount();
-
- for(int i = 0; i < c; ++i) {
- Component m = ((Container)this).getComponent(i);
- if (m instanceof MenuElement) {
- tmp.addElement(m);
- }
- }
-
- MenuElement[] result = new MenuElement[tmp.size()];
- int var7 = 0;
-
- for(int var6 = tmp.size(); var7 < var6; ++var7) {
- result[var7] = (MenuElement)tmp.elementAt(var7);
- }
-
- return result;
- }
-
- public PopupMenuUI getUI() {
- return (PopupMenuUI)super.ui;
- }
-
- public String getUIClassID() {
- return "PopupMenuUI";
- }
-
- private static Window getWindow(Component c) {
- Component w;
- for(w = c; !(w instanceof Window) && w != null; w = w.getParent()) {
- }
-
- return (Window)w;
- }
-
- public void insert(Action a, int index) {
- throw new Error("void insert(Action, int) {} not yet implemented");
- }
-
- public void insert(Component component, int index) {
- if (index < 0) {
- throw new IllegalArgumentException("index less than zero.");
- } else {
- int nitems = ((Container)this).getComponentCount();
- Vector tempItems = new Vector();
-
- for(int i = index; i < nitems; ++i) {
- tempItems.addElement(((Container)this).getComponent(index));
- ((Container)this).remove(index);
- }
-
- this.add(component);
-
- for(int i = 0; i < tempItems.size(); ++i) {
- this.add((Component)tempItems.elementAt(i));
- }
-
- }
- }
-
- public boolean isBorderPainted() {
- return this.paintBorder;
- }
-
- public boolean isLightWeightPopupEnabled() {
- return this.lightWeightPopupEnabled;
- }
-
- private boolean isPopupMenu() {
- return this.invoker != null && !(this.invoker instanceof JMenu);
- }
-
- boolean isSubPopupMenu(JPopupMenu popup) {
- int ncomponents = ((Container)this).getComponentCount();
- Component[] component = ((Container)this).getComponents();
-
- for(int i = 0; i < ncomponents; ++i) {
- Component comp = component[i];
- if (comp instanceof JMenu) {
- JMenu menu = (JMenu)comp;
- JPopupMenu subPopup = menu.getPopupMenu();
- if (subPopup == popup) {
- return true;
- }
-
- if (subPopup.isSubPopupMenu(popup)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public boolean isVisible() {
- return this.popup != null ? this.popup.isShowing() : false;
- }
-
- public void menuSelectionChanged(boolean isIncluded) {
- if (this.invoker instanceof JMenu) {
- JMenu m = (JMenu)this.invoker;
- if (isIncluded) {
- m.setPopupMenuVisible(true);
- } else {
- m.setPopupMenuVisible(false);
- }
- }
-
- if (this.isPopupMenu() && !isIncluded) {
- this.setVisible(false);
- }
-
- }
-
- public void pack() {
- if (this.popup != null) {
- this.popup.pack();
- }
-
- }
-
- protected void paintBorder(Graphics g) {
- if (this.isBorderPainted()) {
- super.paintBorder(g);
- }
-
- }
-
- private boolean popupFit(Rectangle popupRectInScreen) {
- if (this.invoker != null) {
- for(Container parent = this.invoker.getParent(); parent != null; parent = ((Component)parent).getParent()) {
- if (parent instanceof JFrame || parent instanceof JDialog) {
- return SwingUtilities.isRectangleContainingRectangle(((Component)parent).getBounds(), popupRectInScreen);
- }
-
- if (parent instanceof JApplet) {
- Rectangle r = ((Component)parent).getBounds();
- Point p = ((Component)parent).getLocationOnScreen();
- r.x = p.x;
- r.y = p.y;
- return SwingUtilities.isRectangleContainingRectangle(r, popupRectInScreen);
- }
-
- if (parent instanceof Frame) {
- return SwingUtilities.isRectangleContainingRectangle(((Component)parent).getBounds(), popupRectInScreen);
- }
- }
- }
-
- return false;
- }
-
- public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager) {
- }
-
- public void processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager) {
- }
-
- private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
- s.defaultReadObject();
- Vector values = (Vector)s.readObject();
- int indexCounter = 0;
- int maxCounter = values.size();
- if (indexCounter < maxCounter && values.elementAt(indexCounter).equals("invoker")) {
- ++indexCounter;
- this.invoker = (Component)values.elementAt(indexCounter);
- ++indexCounter;
- }
-
- if (indexCounter < maxCounter && values.elementAt(indexCounter).equals("popup")) {
- ++indexCounter;
- this.popup = (Popup)values.elementAt(indexCounter);
- ++indexCounter;
- }
-
- if (indexCounter < maxCounter && values.elementAt(indexCounter).equals("frame")) {
- ++indexCounter;
- this.frame = (Frame)values.elementAt(indexCounter);
- ++indexCounter;
- }
-
- }
-
- static synchronized void recycleHeavyPopup(Popup aPopup) {
- Frame f = getFrame((Component)aPopup);
- Hashtable heavyPopupCache = getHeavyPopupCache();
- Vector cache;
- if (heavyPopupCache.containsKey(f)) {
- cache = (Vector)heavyPopupCache.get(f);
- } else {
- cache = new Vector();
- heavyPopupCache.put(f, cache);
- ((Window)f).addWindowListener(new 2(f));
- }
-
- if (cache.size() < 5) {
- cache.addElement(aPopup);
- }
-
- }
-
- static synchronized void recycleLightPopup(Popup aPopup) {
- Vector lightPopupCache = getLightPopupCache();
- if (lightPopupCache.size() < 5) {
- lightPopupCache.addElement(aPopup);
- }
-
- }
-
- static synchronized void recycleMediumPopup(Popup aPopup) {
- Vector mediumPopupCache = getMediumPopupCache();
- if (mediumPopupCache.size() < 5) {
- mediumPopupCache.addElement(aPopup);
- }
-
- }
-
- static void recyclePopup(Popup aPopup) {
- if (aPopup instanceof JPanelPopup) {
- recycleLightPopup(aPopup);
- } else if (aPopup instanceof WindowPopup) {
- recycleHeavyPopup(aPopup);
- } else if (aPopup instanceof PanelPopup) {
- recycleMediumPopup(aPopup);
- }
-
- }
-
- public void removePopupMenuListener(PopupMenuListener l) {
- EventListenerList var10000 = super.listenerList;
- Class var10001 = class$com$sun$java$swing$event$PopupMenuListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.PopupMenuListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$com$sun$java$swing$event$PopupMenuListener = var10001;
- }
-
- var10000.remove(var10001, l);
- }
-
- private void replacePopup(int newType) {
- this.popup.removeComponent(this);
- recyclePopup(this.popup);
- switch (newType) {
- case 0:
- this.popup = this.createLightWeightPopup();
- break;
- case 1:
- this.popup = this.createMediumWeightPopup();
- break;
- case 2:
- this.popup = this.createHeavyWeightPopup();
- }
-
- this.popup.setLocationOnScreen(this.desiredLocationX, this.desiredLocationY);
- this.popup.addComponent(this, "Center");
- ((Container)this).invalidate();
- this.popup.setBackground(((Component)this).getBackground());
- this.popup.pack();
- }
-
- private void requestAddGrab(Component invoker, Popup aPopup) {
- if (this.mouseGrabber == null) {
- this.mouseGrabber = new MouseGrabber(this);
- }
-
- Window ancestor = getWindow(invoker);
- this.mouseGrabber.grabContainer(ancestor, aPopup.getComponent());
- }
-
- private void requestRemoveGrab(Component invoker) {
- if (this.mouseGrabber != null) {
- this.mouseGrabber.ungrabContainers();
- }
-
- }
-
- public void setBorderPainted(boolean b) {
- this.paintBorder = b;
- ((Component)this).repaint();
- }
-
- public static void setDefaultLightWeightPopupEnabled(boolean aFlag) {
- SwingUtilities.appContextPut(defaultLWPopupEnabledKey, new Boolean(aFlag));
- }
-
- public void setInvoker(Component invoker) {
- Component oldInvoker = this.invoker;
- this.invoker = invoker;
- if (oldInvoker != this.invoker && super.ui != null) {
- super.ui.uninstallUI(this);
- super.ui.installUI(this);
- }
-
- ((Container)this).invalidate();
- }
-
- public void setLabel(String label) {
- this.label = label;
- ((JComponent)this).firePropertyChange("label", label, label);
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleVisibleData", label, label);
- }
-
- ((Container)this).invalidate();
- ((Component)this).repaint();
- }
-
- public void setLightWeightPopupEnabled(boolean aFlag) {
- this.lightWeightPopupEnabled = aFlag;
- }
-
- public void setLocation(int x, int y) {
- if (this.popup != null) {
- this.popup.setLocationOnScreen(x, y);
- } else {
- this.desiredLocationX = x;
- this.desiredLocationY = y;
- }
-
- }
-
- public void setPopupSize(int width, int height) {
- this.popup.setSize(width, height);
- }
-
- public void setPopupSize(Dimension d) {
- this.popup.setSize(d.width, d.height);
- }
-
- public void setSelected(Component sel) {
- SingleSelectionModel model = this.getSelectionModel();
- int index = this.getComponentIndex(sel);
- model.setSelectedIndex(index);
- }
-
- public void setSelectionModel(SingleSelectionModel model) {
- this.selectionModel = model;
- }
-
- public void setUI(PopupMenuUI ui) {
- super.setUI(ui);
- }
-
- public void setVisible(boolean b) {
- if (b != this.isVisible()) {
- if (!b) {
- this.getSelectionModel().clearSelection();
- if (this.getRootPopupMenu() == this) {
- this.requestRemoveGrab(this.invoker);
- }
- } else if (this.isPopupMenu() && this.getSubElements().length > 0) {
- MenuElement[] me = new MenuElement[2];
- me[0] = this;
- me[1] = this.getSubElements()[0];
- MenuSelectionManager.defaultManager().setSelectedPath(me);
- }
-
- if (b) {
- boolean shouldDowngradeHeavyWeight = this.ancestorIsDialog(this.invoker);
- this.firePopupMenuWillBecomeVisible();
- switch (this.lastPopupType) {
- case 0:
- this.popup = this.createLightWeightPopup();
- break;
- case 1:
- this.popup = this.createMediumWeightPopup();
- break;
- case 2:
- this.popup = this.createHeavyWeightPopup();
- }
-
- int popupType = this.lastPopupType;
- this.popup.setLocationOnScreen(this.desiredLocationX, this.desiredLocationY);
- this.popup.addComponent(this, "Center");
- this.popup.setBackground(((Component)this).getBackground());
- this.popup.pack();
- Rectangle popupRect = new Rectangle(this.desiredLocationX, this.desiredLocationY, this.popup.getWidth(), this.popup.getHeight());
- byte newPopupType;
- if (this.popupFit(popupRect)) {
- if (this.lightWeightPopupEnabled) {
- newPopupType = 0;
- } else {
- newPopupType = 1;
- }
- } else if (shouldDowngradeHeavyWeight) {
- newPopupType = 1;
- } else {
- newPopupType = 2;
- }
-
- if (newPopupType != popupType) {
- this.replacePopup(newPopupType);
- popupType = newPopupType;
- }
-
- this.lastPopupType = popupType;
- this.popup.show(this.invoker);
- if (this.getRootPopupMenu() == this) {
- this.requestAddGrab(this.invoker, this.popup);
- }
- } else if (this.popup != null) {
- this.firePopupMenuWillBecomeInvisible();
- this.popup.hide();
- this.popup.removeComponent(this);
- recyclePopup(this.popup);
- this.popup = null;
- }
-
- }
- }
-
- public void show(Component invoker, int x, int y) {
- this.setInvoker(invoker);
- Frame newFrame = getFrame(invoker);
- if (newFrame != this.frame && newFrame != null) {
- this.frame = newFrame;
- if (this.popup != null) {
- this.setVisible(false);
- }
- }
-
- Point invokerOrigin = invoker.getLocationOnScreen();
- this.setLocation(invokerOrigin.x + x, invokerOrigin.y + y);
- this.setVisible(true);
- }
-
- public void updateUI() {
- this.setUI((PopupMenuUI)UIManager.getUI(this));
- }
-
- private void writeObject(ObjectOutputStream s) throws IOException {
- Vector values = new Vector();
- s.defaultWriteObject();
- if (this.invoker != null && this.invoker instanceof Serializable) {
- values.addElement("invoker");
- values.addElement(this.invoker);
- }
-
- if (this.popup != null && this.popup instanceof Serializable) {
- values.addElement("popup");
- values.addElement(this.popup);
- }
-
- if (this.frame != null && this.frame instanceof Serializable) {
- values.addElement("frame");
- values.addElement(this.frame);
- }
-
- s.writeObject(values);
- }
-
- static Hashtable access$getHeavyPopupCache() {
- return getHeavyPopupCache();
- }
- }
-